package com.foton.bpc.all.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author RenPu
 * @Date 2023/6/12 15:42
 * @Version 1.0
 * @Description: 服务调用者，参数的封装  配置类
 **/
public class RefrenceConfig {


    /**
     * 注册所需要的配置。例如：host,port等
     */
    private List<RegisterConfig> registerConfigs;


    /**
     * 协议相关的配置。例如：序列化协议为Json等
     */
    private List<ProtocolConfig> protocolConfigs;

    /**
     * 类全类名
     */

    private Class<?> service;

    /**
     * 客户端负载均衡策略
     */

    private String loadBalance;

    /**
     * 版本
     */
    private String version;

    public List<RegisterConfig> getRegisterConfigs() {
        return registerConfigs;
    }

    public void setRegisterConfigs(List<RegisterConfig> registerConfigs) {
        this.registerConfigs = registerConfigs;
    }


    public synchronized void addRegisterConfigs(RegisterConfig registerConfig) {
        if(CollectionUtils.isEmpty(registerConfigs)){
            this.registerConfigs=new ArrayList<RegisterConfig>();
        }
        this.registerConfigs.add(registerConfig);
    }





    public List<ProtocolConfig> getProtocolConfigs() {
        return protocolConfigs;
    }

    public void setProtocolConfigs(List<ProtocolConfig> protocolConfigs) {
        this.protocolConfigs = protocolConfigs;
    }

    public synchronized void addProtocolConfigs(ProtocolConfig protocolConfig) {
        if(CollectionUtils.isEmpty(protocolConfigs)){
            this.protocolConfigs=new ArrayList<ProtocolConfig>();
        }
        this.protocolConfigs.add(protocolConfig);
    }



    public Class<?> getService() {
        return service;
    }

    public void setService(Class<?> service) {
        this.service = service;
    }

    public String getLoadBalance() {
        return loadBalance;
    }

    public void setLoadBalance(String loadBalance) {
        this.loadBalance = loadBalance;
    }


    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }


    public URI toURI(){


        return null;

    }


}
